<template>
  <div class="container home">
    <div class="box center" @click="jump('Center')">
      <h3 class="title">中心AI服务器集群</h3>
      <div class="image-box">
        <img :draggable="false" src="../assets/images/center.png" alt="">
      </div>
    </div>
    <div :class="['line-box', 'line-1', airport ? 'bling1' : '']"></div>
    <div :class="['line-box', 'line-2', hospital ? 'bling2' : '']"></div>
    <div :class="['line-box', 'line-3', school ? 'bling3' : '']"></div>
    <div class="box airport" @click="jump('Airport')">
      <div class="image-box">
        <img :draggable="false" v-if="airport" src="../assets/images/airport-active.png" alt="">
        <img :draggable="false" v-else src="../assets/images/airport.png" alt="">
<!--        <img :draggable="false" src="../assets/images/airport-active.png" alt="">-->
      </div>
      <h3 class="title">机场</h3>
    </div>
    <div class="box hospital" @click="jump('Hospital')">
      <div class="image-box">
<!--        <img :draggable="false" src="../assets/images/hospital-active.png" alt="">-->
        <img :draggable="false" v-if="hospital" src="../assets/images/hospital-active.png" alt="">
        <img :draggable="false" v-else src="../assets/images/hospital.png" alt="">
      </div>
      <h3 class="title">医院</h3>
    </div>
    <div class="box school" @click="jump('School')">
      <div class="image-box">
<!--        <img :draggable="false" src="../assets/images/school-active.png" alt="">-->
        <img :draggable="false" v-if="school" src="../assets/images/school-active.png" alt="">
        <img :draggable="false" v-else src="../assets/images/school.png" alt="">
      </div>
      <h3 class="title">学校</h3>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  name: 'Home',
  components: {},
  data () {
    return {
    }
  },
  computed: {
    ...mapGetters(['airport', 'hospital', 'school'])
  },
  created () {
  },
  mounted () {

  },
  methods: {
    jump(name) {
      this.$router.push({
        name
      })
    }
  },
  beforeDestroy () {
  },
}
</script>

<style scoped lang="less">
/* 定义动画 */
@keyframes bling1 {
  from {
    background-image: url("../assets/images/airport-line-e.png");
    //background-size: 60%;
    //background-position: 20% 50%;
  }
  to {
    background-image: url("../assets/images/airport-line-s.png");
    //background-size: 60%;
    //background-position: 20% 50%;
  }
}
@keyframes bling2 {
  from {
    background-image: url("../assets/images/hospital-line-e.png");
    //background-size: 60%;
    //background-position: 20% 50%;
  }
  to {
    background-image: url("../assets/images/hospital-line-s.png");
    //background-size: 60%;
    //background-position: 20% 50%;
  }
}
@keyframes bling3 {
  from {
    background-image: url("../assets/images/school-line-e.png");
    //background-size: 60%;
    //background-position: 20% 50%;
  }
  to {
    background-image: url("../assets/images/school-line-s.png");
    //background-size: 60%;
    //background-position: 20% 50%;
  }
}

/* 应用动画到元素 */
.bling1 {
  //animation: bling 0s ease-in-out forwards;
  //animation-iteration-count: infinite;
  animation-name: bling1;
  animation-duration: .5s;
  animation-delay: 0ms;
  animation-iteration-count: infinite;
  animation-direction: normal;
  //animation-timing-function: linear;
  //animation-timing-function: cubic-bezier(1, 1, 1, 1);
  animation-fill-mode: none;
}
/* 应用动画到元素 */
.bling2 {
  //animation: bling 0s ease-in-out forwards;
  //animation-iteration-count: infinite;
  animation-name: bling2;
  animation-duration: .5s;
  animation-delay: 0ms;
  animation-iteration-count: infinite;
  animation-direction: normal;
  //animation-timing-function: linear;
  //animation-timing-function: cubic-bezier(1, 1, 1, 1);
  animation-fill-mode: none;
}
/* 应用动画到元素 */
.bling3 {
  //animation: bling 0s ease-in-out forwards;
  //animation-iteration-count: infinite;
  animation-name: bling3;
  animation-duration: .5s;
  animation-delay: 0ms;
  animation-iteration-count: infinite;
  animation-direction: normal;
  //animation-timing-function: linear;
  //animation-timing-function: cubic-bezier(1, 1, 1, 1);
  animation-fill-mode: none;
}

.home {
  position: relative;
}
.line-box {
  width: 50%;
  height: 50%;
  //border: 1px solid #000;
  position: absolute;
  z-index: 1;
  &.line-1 {
    top: 50%;
    left: 0;
    margin-top: -300px;
    background: url("../assets/images/airport-line.png") no-repeat;
    background-size: 56%;
    background-position: 43% 41%;
  }
  &.line-2 {
    top: 50%;
    margin-top: -300px;
    right: 0;
    background: url("../assets/images/hospital-line.png") no-repeat;
    background-size: 58%;
    background-position: 71% 58%;
  }
  &.line-3 {
    height: 100%;
    top: 49%;
    margin-top: -300px;
    left: 29%;
    border-color: #f90;
    background: url("../assets/images/school-line.png") no-repeat;
    background-size: 80%;
    background-position: 0 36%;
    //z-index: 3;
  }
}
.box {
  width: 50%;
  position: absolute;
  //background: #ccc;
  display: flex;
  justify-content: center;
  flex-direction: column;
  align-items: center;
  z-index: 2;
  h3.title {
    text-align: center;
    font-weight: normal;
    font-size: 17px;
    //background: #ccc;
    height: 40px;
    line-height: 40px;
    width: 100%;
    color: #80fafd;
  }
  .image-box {
    width: 90%;
    display: flex;
    justify-content: center;
    align-content: center;
    img {
      display: block;
      width: 100%;
      height: auto;
      margin: 0 auto;
    }
  }
  &.center {
    left: 25%;
    top: 50%;
    margin-top: -300px;
    .image-box {
      width: 70%;
    }
  }
  &.airport {
    left: 0;
    top: 55%;
    margin-top: -150px;
  }
  &.hospital {
    right: 0;
    top: 55%;
    margin-top: -100px;
  }
  &.school {
    left: 25%;
    bottom: 5%;
  }
}

</style>
